import pymysql


# MySQL:源数据库配置信息
# MySQL服务器地址
Source_MySQL_Host = '192.168.1.100'
# MySQL服务端口
Source_MySQL_Port = 3306
# MySQL用户名
Source_MySQL_User = 'root'
# MySQL密码
Source_MySQL_Password = 'summit-1'
# MySQL字符集
Source_MySQL_Charset = 'utf8'
# 源数据库名
Source_DataBase_Name = "db001"
# 源表
Transfer_Source_Table_Name = "tb2001"


# MySQL:目标数据库配置信息
# MySQL服务器地址
Target_MySQL_Host = '192.168.1.100'
# MySQL服务端口
Target_MySQL_Port = 3306
# MySQL用户名
Target_MySQL_User = 'root'
# MySQL密码
Target_MySQL_Password = 'summit-1'
# MySQL字符集
Target_MySQL_Charset = 'utf8'
# 目标数据库名
Target_DataBase_Name = "db002"
# 目标表
Transfer_Target_Table_Name = "tb2002"


# 连接超时'秒'
Default_MySQL_Connect_TimeOut = 120
# 起始时间
Transfer_Condition = "dt < '2017-08-21'"
# # 最大行数
# Transfer_Rows_Per_Batch = 10000
# # 时间？
# Sleep_Second_Per_Batch = 0.5


def get_source_connection():
    """
    根据默认配置返回源数据库连接
    :return: 源数据库连接
    """
    conn = pymysql.connect(
        host=Source_MySQL_Host,
        port=Source_MySQL_Port,
        user=Source_MySQL_User,
        passwd=Source_MySQL_Password,
        connect_timeout=Default_MySQL_Connect_TimeOut,
        charset=Source_MySQL_Charset,
        db=Source_DataBase_Name
    )
    return conn


def get_target_connection():
    """
    根据默认配置返回目标数据库连接
    :return: 目标数据库连接
    """
    conn = pymysql.connect(
        host=Target_MySQL_Host,
        port=Target_MySQL_Port,
        user=Target_MySQL_User,
        passwd=Target_MySQL_Password,
        connect_timeout=Default_MySQL_Connect_TimeOut,
        charset=Target_MySQL_Charset,
        db=Target_DataBase_Name
    )
    return conn
